package sortForeign;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import sum.CityForeignMarriages.SumCityFoMarriagesBean;

import java.io.IOException;

public class sortCityForeignMapper extends Mapper<LongWritable, Text,sortCityForeignBean, SumCityFoMarriagesBean> {
    sortCityForeignBean outKey = new sortCityForeignBean();
    SumCityFoMarriagesBean outValue = new SumCityFoMarriagesBean();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String[] fields = value.toString().split("\t");
        float foreign_marriages = Float.parseFloat(fields[2]);
        outKey.set(foreign_marriages);
        String province = fields[0];
        String city = fields[1];
        outValue.set(province,city);
    }
}
